package com.javabasic.algorithm.leetcode;

import org.junit.Test;

/**
 * @Author xiongmin
 * @Description //TODO
 * @Date 2020/1/30 19:41
 * @Version 1.0
 **/
public class ZigZagConversion {


    public static void main(String[] args) {
        System.out.println("hello");
        System.out.println(convert("PAYPALISHIRING", 3));
    }

    /**
     * 模拟解法
     * @param s
     * @param numRows
     * @return
     */
    public static String convert(String s, int numRows) {
        if (s == null || s.isEmpty()) return s;
        String result = "";
        int len = s.length();
        String[] arr = new String[numRows];
        for (int i = 0; i < numRows; i++) {
            arr[i] = "";
        }
        arr[0] += s.charAt(0);
        int i = 0, j = 0, k = 1;
        while (k < len) {
            while (i + 1 < numRows && k < len) {
                arr[++i] += s.charAt(k++);
            }
            System.out.println(i + " " + j);
            while (i - 1 >= 0 && k < len) {
                arr[--i] += s.charAt(k++);
            }
        }
//        for (int l = 0; l < numRows; l++) {
//            for (int m = 0; m < col; m++) {
//                if (map[l][m] != 0) {
//                    result += map[l][m];
//                }
//                System.out.print(map[l][m]+ " ");
//            }
//            System.out.println();
//        }
        for (int l = 0; l < numRows; l++) {
            result += arr[l];
        }
        return result;

    }
}
